/**
 * Calculator.java
 * 
 * @authors: Connor Gordon, Difan Zhao, Kathleen Lan, Patrick Royal
 */

package utilities;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Group 8
 *         Kathleen's reusable class
 */
public class Calculator {

    /**
     * Empty constructor for Calculator;
     */
    public Calculator () {
    }

    /**
     * Calculates distance between two points as doubles.
     * 
     * @param x1 x-coordinate of first point
     * @param y1 y-coordinate of first point
     * @param x2 x-coordinate of second point
     * @param y2 y-coordinate of second point
     */
    public double distanceBetween (double x1, double y1, double x2, double y2) {
        return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    }

    /**
     * Calculates distance between two points as integers.
     * 
     * @param x1 x-coordinate of first point
     * @param y1 y-coordinate of first point
     * @param x2 x-coordinate of second point
     * @param y2 y-coordinate of second point
     */
    public int distanceBetween (int x1, int y1, int x2, int y2) {
        Double temp = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        return temp.intValue();
    }

    /**
     * Converts a list of Doubles into a list of Integers.
     * 
     * @param list list of elements to be converted
     */
    public static List<Integer> doubleToIntegerList (List<Double> list) {
        List<Integer> integerData = new ArrayList<Integer>();
        for (double d : list) {
            integerData.add((int) d);
        }
        return integerData;
    }
}
